package com.autumn.domain.entities.auditing;

import java.util.Date;

import javax.persistence.Column;

import com.autumn.common.api.domain.entities.auditing.IGmtCreate;
import com.autumn.domain.entities.AbstractEntity;
import com.autumn.mybatis.mapper.annotation.ColumnOrder;
import com.autumn.mybatis.mapper.annotation.Index;

/**
 * 具有新增审计的抽象
 * 
 * @author 老码农
 *         <p>
 *         Description
 *         </p>
 * @date 2017-12-31 21:23:48
 * @param <TPrimaryKey>
 *            主键类型
 */
public abstract class AbstractGmtCreateEntity<TPrimaryKey> extends AbstractEntity<TPrimaryKey> implements IGmtCreate {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2969338981575758840L;	
	

	@ColumnOrder(10000)
	@Column(name = AuditingConsts.COLUMN_GMT_CREATE, nullable = false)
	@Index
	private Date gmtCreate;

	@Override
	public Date getGmtCreate() {
		if (gmtCreate == null) {
			return new Date();
		}
		return this.gmtCreate;
	}

	@Override
	public void setGmtCreate(Date gmtCreate) {
		this.gmtCreate = gmtCreate;
	}
}
